import request from '@/utils/request'

export function getList(params) {
  return request({
    url: '/admin/file/getList',
    method: 'get',
    params
  })
}

export function setStatus(type, id) {
  return request({
    url: '/admin/file/status',
    method: 'post',
    data: {
      type: type,
      id: id
    }
  })
}

export function setRecommand(type, id) {
  return request({
    url: '/admin/file/setRecommend',
    method: 'post',
    data: {
      isRecommend: type,
      id: id
    }
  })
}

// 删除文档
export function del(id) {
  return request({
    url: '/admin/file/del',
    method: 'post',
    data: {
      id: id
    }
  })
}

export function setHeader(ossName, fileName, fileType) {
  return request({
    url: '/admin/file/setDocHeader',
    method: 'post',
    data: {
      oss_name: ossName, // PDF在线位置
      file_name: fileName, // 文件名称
      file_type: fileType // 文件Content-type类型
    }
  })
}

export function addQrCode(id) {
  return request({
    url: '/admin/file/addQrCode',
    method: 'post',
    data: {
      id: id
    }
  })
}

export function upFilePageCount(id, pageCount) {
  return request({
    url: '/admin/file/upFilePageCount',
    method: 'post',
    data: {
      id: id,
      page_count: pageCount
    }
  })
}

export function pdf2png(ossName, pageDir) {
  return request({
    url: '/admin/file/doc2png',
    method: 'post',
    data: {
      oss_name: ossName, // PDF在线位置
      page_dir: pageDir // 页存储地址
    }
  })
}

export function checkTask(taskId) {
  return request({
    url: '/admin/file/checkTask',
    method: 'post',
    data: {
      task_id: taskId
    }
  })
}

export function add(data) {
  return request({
    url: '/admin/file/apiAdd',
    method: 'post',
    data: data
  })
}

export function edit(data) {
  return request({
    url: '/admin/file/apiEdit',
    method: 'post',
    data: data
  })
}

